<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>WLog: ILevel.cpp源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- 制作者 Doxygen 1.5.8 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="namespaces.html"><span>名字空间</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<h1>ILevel.cpp</h1><a href="ILevel_8cpp.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#include "<a class="code" href="ILevel_8h.html">ILevel.h</a>"</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="Common_8h.html">Common.h</a>"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="WLDefine_8h.html">WLDefine.h</a>"</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include "<a class="code" href="IOuter_8h.html">IOuter.h</a>"</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="keyword">namespace </span>WLog
<a name="l00009"></a>00009 {
<a name="l00010"></a><a class="code" href="namespaceWLog.html#6315f1351a7f92cf5bb70536413cb0da">00010</a>     <span class="keywordtype">bool</span> <a class="code" href="namespaceWLog.html#6315f1351a7f92cf5bb70536413cb0da">cb_trimFileName</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a>* pRecord, <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>*)
<a name="l00011"></a>00011     {
<a name="l00012"></a>00012         <span class="keywordflow">if</span> (<a class="code" href="namespaceWLog.html#4eef0f756406a40b36699c3f95c5270e">bTrimFileName</a>)
<a name="l00013"></a>00013         {
<a name="l00014"></a>00014 <span class="preprocessor">#ifdef _WIN32</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>            <span class="keywordtype">char</span> chSplit = <span class="charliteral">'\\'</span>;
<a name="l00016"></a>00016 <span class="preprocessor">#else</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>            <span class="keywordtype">char</span> chSplit = <span class="charliteral">'/'</span>;
<a name="l00018"></a>00018 <span class="preprocessor">#endif // _WIN32</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>            <span class="keywordtype">size_t</span> iIndex = pRecord-&gt;<a class="code" href="classWLog_1_1Record.html#d82ac9e750430e01f1895186a8cc70bf">m_strFileName</a>.find_last_of(chSplit);
<a name="l00020"></a>00020             <span class="keywordflow">if</span> (string::npos != iIndex)
<a name="l00021"></a>00021             {
<a name="l00022"></a>00022                 pRecord-&gt;<a class="code" href="classWLog_1_1Record.html#d82ac9e750430e01f1895186a8cc70bf">m_strFileName</a> = pRecord-&gt;<a class="code" href="classWLog_1_1Record.html#d82ac9e750430e01f1895186a8cc70bf">m_strFileName</a>.substr(iIndex+1);
<a name="l00023"></a>00023             }
<a name="l00024"></a>00024         }
<a name="l00025"></a>00025         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00026"></a>00026     }
<a name="l00027"></a>00027 
<a name="l00028"></a><a class="code" href="namespaceWLog.html#9ceab8f8dc49e6ae5886332c430b3573">00028</a>     <span class="keywordtype">bool</span> <a class="code" href="namespaceWLog.html#9ceab8f8dc49e6ae5886332c430b3573">cb_exit</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a>*, <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* pOuter)<span class="comment">/* pRecord*/</span>
<a name="l00029"></a>00029     {
<a name="l00030"></a>00030         pOuter-&gt;<a class="code" href="classWLog_1_1IOuter.html#7e635ff649baefb3685ca9a7868965b7" title="通知结束输出，做一些输出事后工作，如XML可以在这里输出根结点的结尾。...">noticeEndOut</a>();
<a name="l00031"></a>00031         (void)exit(1);
<a name="l00032"></a>00032     }
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="namespaceWLog.html#05e19038a875320b3c71790d92a282cf">00034</a>     <span class="keywordtype">bool</span> <a class="code" href="namespaceWLog.html#05e19038a875320b3c71790d92a282cf">cb_assert</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a>*, <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* pOuter)<span class="comment">/* pRecord*/</span>
<a name="l00035"></a>00035     {
<a name="l00036"></a>00036         <span class="comment">/*string strSay = "File:";</span>
<a name="l00037"></a>00037 <span class="comment">        strSay += pRecord-&gt;m_strFileName;</span>
<a name="l00038"></a>00038 <span class="comment">        strSay += " : " + pRecord-&gt;m_strFuncName + "(" + l2str(pRecord-&gt;m_nLine) + ")\n\t";</span>
<a name="l00039"></a>00039 <span class="comment">        strSay += pRecord-&gt;m_strMsg + "\n";*/</span>
<a name="l00040"></a>00040         pOuter-&gt;<a class="code" href="classWLog_1_1IOuter.html#7e635ff649baefb3685ca9a7868965b7" title="通知结束输出，做一些输出事后工作，如XML可以在这里输出根结点的结尾。...">noticeEndOut</a>();
<a name="l00041"></a>00041         assert(<span class="keyword">false</span>);
<a name="l00042"></a>00042 
<a name="l00043"></a>00043         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00044"></a>00044     }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="classWLog_1_1ILevel.html#0188823b552c9a59be13aff007353b3f">00046</a>     <a class="code" href="classWLog_1_1ILevel.html#0188823b552c9a59be13aff007353b3f">ILevel::ILevel</a>(<span class="keywordtype">int</span> iLevel, <span class="keyword">const</span> <span class="keywordtype">char</span>* szName, <span class="keyword">const</span> <span class="keywordtype">char</span>* szDscrp, <span class="keywordtype">int</span> iSigned <span class="comment">/*= SIGNED_OUT_ALL*/</span>, <a class="code" href="namespaceWLog.html#fc8bd5f12f250893cf48c07b699a247d">FunCallBack</a> cbBefore <span class="comment">/*= cb_trimFileName*/</span>, <a class="code" href="namespaceWLog.html#fc8bd5f12f250893cf48c07b699a247d">FunCallBack</a> cbAfter <span class="comment">/*= 0*/</span>)
<a name="l00047"></a>00047         : m_iLevel(iLevel), m_strName(szName), m_strDscrp(szDscrp), m_iSign(iSigned), m_callBackBefore(cbBefore), m_callBackAfter(cbAfter)
<a name="l00048"></a>00048     {
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     }
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="classWLog_1_1ILevel.html#5b35f47cff2006f78a3f141979940eeb">00052</a>     <a class="code" href="classWLog_1_1ILevel.html#5b35f47cff2006f78a3f141979940eeb">ILevel::~ILevel</a>()
<a name="l00053"></a>00053     {
<a name="l00054"></a>00054 
<a name="l00055"></a>00055     }
<a name="l00056"></a>00056     
<a name="l00057"></a><a class="code" href="classWLog_1_1ILevel.html#652b09fa23f53092827c789330c53095">00057</a>     <span class="keywordtype">int</span> <a class="code" href="classWLog_1_1ILevel.html#652b09fa23f53092827c789330c53095" title="得到当前Log定义的级别.">ILevel::getLevel</a>()<span class="keyword"> const</span>
<a name="l00058"></a>00058 <span class="keyword">    </span>{
<a name="l00059"></a>00059         <span class="keywordflow">return</span> m_iLevel;
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061         
<a name="l00062"></a><a class="code" href="classWLog_1_1ILevel.html#4e06cea4bbd31aae2a9170b24e7d6657">00062</a>     <span class="keywordtype">string</span> <a class="code" href="classWLog_1_1ILevel.html#4e06cea4bbd31aae2a9170b24e7d6657" title="得到当前Log的名称.">ILevel::getName</a>()<span class="keyword"> const</span>
<a name="l00063"></a>00063 <span class="keyword">    </span>{
<a name="l00064"></a>00064         <span class="keywordflow">return</span> m_strName;
<a name="l00065"></a>00065     }
<a name="l00066"></a>00066         
<a name="l00067"></a><a class="code" href="classWLog_1_1ILevel.html#7b8ce7477e0e4c646ac286d48aa2d2e4">00067</a>     <span class="keywordtype">string</span> <a class="code" href="classWLog_1_1ILevel.html#7b8ce7477e0e4c646ac286d48aa2d2e4" title="得到当前Log的描述.">ILevel::getDscrp</a>()<span class="keyword"> const</span>
<a name="l00068"></a>00068 <span class="keyword">    </span>{
<a name="l00069"></a>00069         <span class="keywordflow">return</span> m_strDscrp;
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00072"></a><a class="code" href="classWLog_1_1ILevel.html#c5ee0c8e7bd470d233535d45655d889e">00072</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#c5ee0c8e7bd470d233535d45655d889e" title="是否要输出“名称”">ILevel::bOutName</a>()<span class="keyword"> const</span>
<a name="l00073"></a>00073 <span class="keyword">    </span>{
<a name="l00074"></a>00074         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#0dd54d262b6f14f4bc391a308ed13a7f">OUT_NAME</a>);
<a name="l00075"></a>00075     }
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="classWLog_1_1ILevel.html#d436d736b300882a450926b59cd9c546">00077</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#d436d736b300882a450926b59cd9c546" title="是否要输出“描述”">ILevel::bOutDscrp</a>()<span class="keyword"> const</span>
<a name="l00078"></a>00078 <span class="keyword">    </span>{
<a name="l00079"></a>00079         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#f23118c73adabada3de7341a278b9771">OUT_DSCRP</a>);
<a name="l00080"></a>00080     }
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="classWLog_1_1ILevel.html#fdc93101a0cba201cf5dcdf6183a74a2">00082</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#fdc93101a0cba201cf5dcdf6183a74a2" title="是否要输出“行号”">ILevel::bOutLineNo</a>()<span class="keyword"> const</span>
<a name="l00083"></a>00083 <span class="keyword">    </span>{
<a name="l00084"></a>00084         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#4f175ae46d9e17de3260cc4f76e75177">OUT_LINENO</a>);
<a name="l00085"></a>00085     }
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="classWLog_1_1ILevel.html#1f6651825c0af325a2f909b12b8857de">00087</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#1f6651825c0af325a2f909b12b8857de" title="是否要输出“方法名”">ILevel::bOutFuncName</a>()<span class="keyword"> const</span>
<a name="l00088"></a>00088 <span class="keyword">    </span>{
<a name="l00089"></a>00089         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#1940b107d0fdbf0dc6bb29b2c2c828a9">OUT_FUNCNAME</a>);
<a name="l00090"></a>00090     }
<a name="l00091"></a>00091 
<a name="l00092"></a><a class="code" href="classWLog_1_1ILevel.html#83164649d0ca90645038df2e05f1843a">00092</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#83164649d0ca90645038df2e05f1843a" title="是否要输出“文件名”">ILevel::bOutFileName</a>()<span class="keyword"> const</span>
<a name="l00093"></a>00093 <span class="keyword">    </span>{
<a name="l00094"></a>00094         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#8a1cb3712bd7a21dd934f2d46e3d5021">OUT_FILENAME</a>);
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096 
<a name="l00097"></a><a class="code" href="classWLog_1_1ILevel.html#86121504cef5e39ec3425376dd10ceeb">00097</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#86121504cef5e39ec3425376dd10ceeb" title="是否要输出“日志记录时间”">ILevel::bOutTime</a>()<span class="keyword"> const</span>
<a name="l00098"></a>00098 <span class="keyword">    </span>{
<a name="l00099"></a>00099         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#c3429870eb853c3b46e43b7687c5fb75">OUT_TIME</a>);
<a name="l00100"></a>00100     }
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="classWLog_1_1ILevel.html#4c1def9de4e28f9a29a02dead8824a9f">00102</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#4c1def9de4e28f9a29a02dead8824a9f" title="是否在消息输出后输出“新行”">ILevel::bNewLine</a>()<span class="keyword"> const</span>
<a name="l00103"></a>00103 <span class="keyword">    </span>{
<a name="l00104"></a>00104         <span class="keywordflow">return</span> <a class="code" href="ILevel_8h.html#b744fc9817e3580fae60b2b5d6838261">SIGNED_GET_BOOL</a>(m_iSign, <a class="code" href="ILevel_8h.html#86e5a01783a27ce4b5b999ecc85de9ee">OUT_NEWLINE</a>);
<a name="l00105"></a>00105     }
<a name="l00106"></a>00106     
<a name="l00107"></a><a class="code" href="classWLog_1_1ILevel.html#995896554a53b1e03c0617a36d3b3afc">00107</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#995896554a53b1e03c0617a36d3b3afc" title="回调函数，在输出前调用，对此级别Log Record 提前处理.">ILevel::callBack_BeforeOut</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a>* pRecord, <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* pOuter)
<a name="l00108"></a>00108     {
<a name="l00109"></a>00109         <span class="keywordflow">if</span> (m_callBackBefore)
<a name="l00110"></a>00110         {
<a name="l00111"></a>00111             <span class="keywordflow">return</span> m_callBackBefore(pRecord, pOuter);
<a name="l00112"></a>00112         }
<a name="l00113"></a>00113         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00114"></a>00114     }
<a name="l00115"></a>00115 
<a name="l00116"></a><a class="code" href="classWLog_1_1ILevel.html#ff3a60a5f597e84874c9f95adc34100e">00116</a>     <span class="keywordtype">bool</span> <a class="code" href="classWLog_1_1ILevel.html#ff3a60a5f597e84874c9f95adc34100e" title="回调函数，在输出后调用，对此级别Log作善后处理.">ILevel::callBack_AfterOut</a>(<a class="code" href="classWLog_1_1Record.html" title="记录类，记录一条信息的所有字段。">Record</a>* pRecord, <a class="code" href="classWLog_1_1IOuter.html" title="Interface for output Record with define Log Level.">IOuter</a>* pOuter)
<a name="l00117"></a>00117     {
<a name="l00118"></a>00118         <span class="keywordflow">if</span> (m_callBackAfter)
<a name="l00119"></a>00119         {
<a name="l00120"></a>00120             <span class="keywordflow">return</span> m_callBackAfter(pRecord, pOuter);
<a name="l00121"></a>00121         }
<a name="l00122"></a>00122         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00123"></a>00123     }
<a name="l00124"></a>00124 }
</pre></div></div>
<hr>
<address style="align: right;">
  Generated on Mon Apr 6 21:08:12 2009 for WLog by 韦体东<img src="logo.png" align="middle"/></address>
</body>
</html>
